package com.lee.lease.common.custom.exception;

import com.lee.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * ClassName: GlobalExceptionHandler
 * Package: com.lee.lease.web.admin.custom.globalException
 * Description:
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)	//指定异常类型是最大的异常，所以是全局异常处理器
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail();   //返回指定格式
    }

    @ExceptionHandler(LeaseException.class)
    public Result error2(LeaseException e){
        e.printStackTrace();
        return Result.fail(e.getCode(),e.getMessage());
    }
}
